import { Constant } from "../../config/Constant";

/**
 * 大量的性能浪费,上线要关闭
 * */
export class logUtil {

    LOG_LEVEL = {
        TRACE: 'trace',
        LOG: 'log',
        INFO: 'info',
        WARN: 'warn',
        ERROR: 'error',
    };

    private static _instance: logUtil = null!;

    public static get instance() {
        if (this._instance) {
            return this._instance;
        }

        this._instance = new logUtil();
        return this._instance;
    }

    /**
     * 自定义日志等级
     * @param {string} nowConLevel 当前位置日志等级
     * @param {string} logContentLevel 全局自定义日志等级
     * @param {string} LogLevel 日志输出等级,依托logUtil.LOG_LEVEL
     * @param {any[]} ...data 输出内容
     */
    public log1(nowConLevel: string, logContentLevel: string,LogLevel:string ,...data: any[] ){
        if(logContentLevel==Constant.LOG_ALL_LABEL){
            console[LogLevel](...data);
            return
        }
        if(logContentLevel.includes(nowConLevel)){
            console[LogLevel](...data);
        }
    }

    /**
     * 常用精简版
     * @param {string} nowConLevel 当前位置日志等级
     * @param {any[]} ...data 输出内容
     */
    public log(nowConLevel: string,...data: any[]){
        this.log1(nowConLevel,Constant.LOG_CONTENT_LEVEL,this.LOG_LEVEL.LOG,nowConLevel,...data)
    }
}
